<?php 
	class module_menu extends module
	{
		public $content;
		public function get_content($name='')
		{
			$content = '';
			$query = "SELECT m.id,m.title,m.link,m.level,m.description,t.show_items_des FROM menu as m LEFT JOIN menu_types as t ON m.menutype = t.menutype WHERE m.menutype='$name' AND m.state=1 ORDER BY m.display_order";
			$result = mysql_query($query) or die(mysql_error());
			$pre_lvl = 1;
			$content = $content.'<ul class="'.$name.'">';
			$count = 0;
			while ($row = mysql_fetch_array($result)) {
				if ($pre_lvl < intval($row[level])) {
					$content = $content.'<ul class="sub-menu">';
					$pre_lvl = intval($row[level]);
				}
				elseif ($pre_lvl == intval($row[level])){
					if ($count !== 0)
						$content = $content.'</li>';
					else 
						$count = 1;
				}
				else {
					$content = $content.'</li></ul></li>';
					$pre_lvl = intval($row[level]);
				}
				$des = '';
				if (intval($row[show_items_des]))
					$des = '<span>'.$row[description].'</span>';
				$content = $content.'<li><a href="'.$row[link].'"><strong>'.$row[title].'</strong>'.$des.'</a>';
			}
			$content = $content.'</li>';
			if ($pre_lvl > 1)
				$content = $content.'</ul></li>';
			$content = $content.'</ul>';
			echo $content;
		}
	}
?>